package com.mall.service.eshop;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mall.client.eshop.EshopCompanyService;
import com.mall.custom.dao.read.EshopCompanyReadMapper;
import com.mall.custom.dao.write.EshopCompanyWriteMapper;
import com.mall.pojo.EshopCompany;

@Service
public class EshopCompanyServiceImpl implements EshopCompanyService {
	
	@Autowired
	private EshopCompanyReadMapper eshopCompanyReadMapper;
	@Autowired
	private EshopCompanyWriteMapper eshopCompanyWriteMapper;

	/**
	 * 插入店铺所属公司
	 * @param eshopCompany
	 * @return
	 */
	@Override
	public int insertEshopCompanyByEshopCompany(EshopCompany eshopCompany) {
		// TODO Auto-generated method stub
		return this.eshopCompanyWriteMapper.insert(eshopCompany);
	}

	/**
	 * 修改店铺所属公司信息
	 * @param eshopCom
	 * @param eshopCompany
	 * @return
	 */
	@Override
	public int modifyEshopCompanyByEshopCompany(EshopCompany eshopCompany,EshopCompany existEshopCompany) {
		if(existEshopCompany != null){
			eshopCompany.setId(existEshopCompany.getId());
			eshopCompany.setSaleEshopId(existEshopCompany.getSaleEshopId());
			eshopCompany.setGmtCreate(existEshopCompany.getGmtCreate());
		}
		return this.eshopCompanyWriteMapper.updateByPrimaryKey(eshopCompany);
	}

	/**
	 * 删除店铺所属公司
	 * @param eshopCom
	 * @param id
	 * @return
	 */
	@Override
	public int deleteEshopCompanyByEshopCompanyById(Long id) {
		// TODO Auto-generated method stub
		return this.eshopCompanyWriteMapper.deleteByPrimaryKey(id);
	}

	/**
	 * 获得店铺所属公司
	 * @param eshopCom
	 * @param id
	 * @return
	 */
	@Override
	public EshopCompany getEshopCompanyByEshopCompanyId(Long id) {
		if(id == null || id <= 0){
			return null;
		}
		return this.eshopCompanyReadMapper.selectByPrimaryKey(id);
	}

	@Override
	public int modifyEshopCompanyByKey(EshopCompany eshopCompany) {
		// TODO Auto-generated method stub
		return this.eshopCompanyWriteMapper.updateByPrimaryKey(eshopCompany);
	}


}
